<%@page import="org.json.JSONObject"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@page import="org.json.JSONArray"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<% 
	JSONArray jsonA = (JSONArray)request.getAttribute("array");
	request.setAttribute("comingFrom","order");
%>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ajax.js"></script>
<title>COMMANDE</title>
</head>
<body>
<center>
<h1>CATALOGUE</h1>
<form ACTION="" METHOD='POST'>
<table border="1px">
	<tr>
		<th>Code produit</th>
		<th>Libellé produit</th>
		<th>Quantité</th>
		<th>Délais</th>
		<th>Total</th>
	</tr>
	<% for(int i=0;i<jsonA.length();i++)
			{
				out.println("<tr>");				
				JSONObject json = (JSONObject) jsonA.getJSONObject(i);				
				
				out.println("<td id=\"json.getInt(\"productId\")\">"+json.getInt("productId")+"</td>");
				out.println("<td>"+json.getString("productName")+"</td>");
				out.println("<td><input type='text' name='quantity' id='quantity"+(i+1)+"' value='0' size='5' onchange='alert($(this).val());'></input></td>");
				out.println("<td name='delay' id='delay"+(i+1)+"' size='5'></td>");
				out.println("<td name='price' id='price"+(i+1)+"' size='5'></td>");
					
				out.println("</tr>");
				
			}
	%> 
	<tr>
		<td>Délais total de livraison :</td>
		<td><INPUT TYPE='TEXT' NAME='totaldelay' ID='totaldelay'
			SIZE='30'></td>
	</tr>
	<tr>
		<td><INPUT TYPE='hidden' NAME='comingFrom' value='order' SIZE='30'></td>
	</tr>
	<tr>
		<td><INPUT TYPE='SUBMIT' VALUE='Valider' /></td>
		<!-- <td><INPUT TYPE='SUBMIT' VALUE='Annuler' /></td> -->
	</tr>
</table>
</form>
</center>
</body>
</html>